import { download } from '@/utils/download-util';
import type { downloadParam } from '@/utils/download-util';
import request from '@/utils/request';
import type { ResponseBaseData } from '@/api/model/baseModel';

/**
 * 获取导入历史数据
 * @param {Object} queryParam
 * @param {Object} tableName
 */
export function getExcelImportHis(queryParam, tableName) {
  return request({
    url: `appsys/excelimport/ExcelImportRest/result/v1/${tableName}`,
    data: queryParam,
    method: 'post'
  });
}

/** 根据id删除数据 */
export function delExcelImportHis(id): Promise<ResponseBaseData<any>> {
  return request({
    url: `/appsys/excelimport/ExcelImportRest/delete/${id}/v1`,
    method: 'delete'
  });
}

/**
 * 下载错误数据
 * @param {Object} param
 */
export function downloadErrorFile(param) {
  const downloadDto = {
    url: `/appsys/excelimport/ExcelImportRest/download/errorFile/v1/${param}`,
    data: null,
    method: 'get'
  } as downloadParam;
  return download(downloadDto);
}
